package preferencePackage;

import mapPackage.ITronconNonModifiable;
import mapPackage.IVille;
import mapPackage.IVilleNonModifiable;
import mapPackage.MapException;
import mapPackage.tailleVille.STailleVille;
import xmlPackage.Carte;

public class Pref_TailleVilleVoulue extends Preference 
{
	private STailleVille taille;
	
	public Pref_TailleVilleVoulue(int classement, boolean positif , STailleVille taille) 
	{
		super(classement, positif);
		this.taille = taille;
	}

	public float evaluerDestination(IVilleNonModifiable villeDepart , ITronconNonModifiable troncon)
	{
		float score = 0 ;
		try 
		{
			IVille dest = Carte.GetInstance().getVille( troncon.getAutreVille( villeDepart.getNom() ) );
			
			if(positif)
			{
				if( dest.getTailleVille().equals(taille) )score = 0;
				else score = 1;
			}
			else
			{
				if( !dest.getTailleVille().equals(taille) )score = 0;
				else score = 1;
			}
			
			return score * classement;
		}
		catch (MapException e) {e.printStackTrace();}
		return 1;
	}
	
}
